package com.ruoyi.web.controller.snmp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SnmpDevicetype;
import com.ruoyi.system.service.ISnmpDevicetypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Controller
 *
 * @author ruoyi
 * @date 2025-08-22
 */
@RestController
@RequestMapping("/snmp/devicetype")
public class SnmpDevicetypeController extends BaseController
{
    @Autowired
    private ISnmpDevicetypeService snmpDevicetypeService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:devicetype:list')")
    @GetMapping("/list")
    public TableDataInfo list(SnmpDevicetype snmpDevicetype)
    {
        startPage();
        List<SnmpDevicetype> list = snmpDevicetypeService.selectSnmpDevicetypeList(snmpDevicetype);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:devicetype:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SnmpDevicetype snmpDevicetype)
    {
        List<SnmpDevicetype> list = snmpDevicetypeService.selectSnmpDevicetypeList(snmpDevicetype);
        ExcelUtil<SnmpDevicetype> util = new ExcelUtil<SnmpDevicetype>(SnmpDevicetype.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:devicetype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(snmpDevicetypeService.selectSnmpDevicetypeById(id));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('snmp:devicetype:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SnmpDevicetype snmpDevicetype)
    {
        return toAjax(snmpDevicetypeService.insertSnmpDevicetype(snmpDevicetype));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('snmp:devicetype:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SnmpDevicetype snmpDevicetype)
    {
        return toAjax(snmpDevicetypeService.updateSnmpDevicetype(snmpDevicetype));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('snmp:devicetype:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(snmpDevicetypeService.deleteSnmpDevicetypeByIds(ids));
    }
}
